/*--------------------------------------------------------------
 * File: demo24.c 编码类型：C语言  UTF-8
 * Author WRS (1352509846@qq.com)
 * 功能: 求两数的最大公约数
 * Version 0.1
 * Date 2022-01-17 
 * 
 * @copyright Copyright (c) 2022
 * 
----------------------------------------------------------------*/
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int n1,n2,i;
    int ret;
    printf("请输入两个数：");
    scanf("%d %d",&n1,&n2);

    // 如果输入的数负数，将其转换为正数
    n1 = (n1>0) ? n1: -n1;
    n2 = (n2>0) ? n2: -n2;
    while (n1!=n2)
    {
        if(n1>n2)
            n1 -= n2;
        else
            n2 -= n1;
    }   
    printf("最大公约数是%d\n",n1);
    return 0;
}
